package com.wantupai.mvp.framework.base.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.wantupai.mvp.R;


/**
 * @author :Created by zhangqing on 2018/08/24 10:37
 * @description :
 * @email :1423118197@qq.com
 * @classpath : cn.doolii.mvp.framework.base.view.EmptyView
 */
public class EmptyView extends LinearLayout
{
    ImageView imageView;

    public EmptyView(Context context)
    {
        this(context, null);
    }

    public EmptyView(Context context, @Nullable AttributeSet attrs)
    {
        this(context, attrs, 0);
    }

    public EmptyView(Context context, @Nullable AttributeSet attrs, int defStyleAttr)
    {
        super(context, attrs, defStyleAttr);
        LayoutInflater.from(context).inflate(R.layout.empty_view, this, true);
        setHorizontalGravity(VERTICAL);
        setGravity(Gravity.CENTER);
        imageView = findViewById(R.id.empty_image);

    }

    @Override
    public void onAttachedToWindow()
    {
        super.onAttachedToWindow();
        openAnimation();
    }


    @Override
    public void onDetachedFromWindow()
    {
        super.onDetachedFromWindow();
        closeAnimation();
    }

    public void openAnimation()
    {
        setVisibility(VISIBLE);
    }

    public void closeAnimation()
    {
        setVisibility(View.GONE);
    }
}
